package com.ruoyi.wechat.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wechat.domain.CScenicSpots;
import com.ruoyi.wechat.service.ICScenicSpotsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wechat/spots")
public class WxScenicSpotsController extends BaseController {

    @Autowired
    private ICScenicSpotsService cScenicSpotsService;

    //根据营地Id查询周边景点列表
    @GetMapping("/getInfoByCampId/{campId}")
    public AjaxResult getInfoByCampId(@PathVariable("campId") String campId) {
        if (campId == null) {
            return error("营地Id不能为空");
        }
        List<CScenicSpots> list = cScenicSpotsService.getInfoByCampId(campId);
        return success(list);
    }

   //添加周边景点并提交审批
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CScenicSpots cScenicSpots){
        if (cScenicSpots == null) {
            return error("数据不能为空");
        }
        if (cScenicSpots.getCampId() == null) {
            return error("营地Id不能为空");
        }
        if (cScenicSpots.getScenicName() == null) {
            return error("景点名称不能为空");
        }
        if (cScenicSpots.getLatitude() == null || cScenicSpots.getLongitude() == null) {
            return error("经纬度不能为空");
        }
        return toAjax(cScenicSpotsService.insertCScenicSpots(cScenicSpots));
    }
    @DeleteMapping("/{scenicIds}")
    public AjaxResult remove(@PathVariable String[] scenicIds)
    {
        return toAjax(cScenicSpotsService.deleteCScenicSpotsByScenicIds(scenicIds));
    }
}
